<template>
    <header>
        <section>
            <form action="baidu.com" onsubmit="return false">
                <label for="title">ToDoList</label>
                <input type="text" placeholder="添加ToDo" v-model="msg" @keyup.enter="addFun" />
            </form>
        </section>
    </header>
</template>
<script setup>
import {ref} from 'vue'
// 1. 子传父
  let emit = defineEmits(['addTodos'])
  let msg = ref('') // 双向数据绑定关联的数据
  const addFun = ()=>{ // 点击回车触发的事件
    emit('addTodos' , msg.value)//发生数据
    msg.value = ''//情况数据
  }
  // -----------------------------
</script>
<script>
  export default {
    name:"todo-add"
  }
</script>
<style scoped>
header {
  height: 50px;
  background: #333;
  background: rgba(47, 47, 47, 0.98);
}
label {
  float: left;
  width: 100px;
  line-height: 50px;
  color: #ddd;
  font-size: 24px;
  cursor: pointer;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
header input {
  float: right;
  width: 60%;
  height: 24px;
  margin-top: 12px;
  text-indent: 10px;
  border-radius: 5px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.24),0 1px 6px rgba(0, 0, 0, 0.45) inset;
  border: none;
}
</style>